-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-129013: Don't expose async_generator_wrapped_value
in PY_YIELD
callbacks
#129031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I don't know these parts of the Python code base, I cannot review your change. |
Thanks for this PR, I just found my way here as I was hit by the same bug! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a couple of comments and a question: how is a user supposed to distinguish between yield
and await
in the callback?
asyncio.run(main()) | ||
sys.monitoring.set_events(0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would seem slightly cleaner.
asyncio.run(main()) | |
sys.monitoring.set_events(0, 0) | |
try: | |
asyncio.run(main()) | |
finally: | |
sys.monitoring.clear_tool_id(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not disagreeing, but I'd rather stay consistent with the rest of the file. try
/finally
doesn't seem to be used with set_events(0, 0)
in these tests, so I'm going to skip it for now. Sounds reasonable to add that in a follow-up PR, though.
Hmm, I guess you could check if its an instance of |
Futures being awaited are not the issue – it's things like |
I do agree that ideally we should have separate |
Perhaps the easiest backwards compatible solution is to expose the wrapper type and its contained value to Python code? @vstinner any thoughts so far? |
I would really rather not expose our implementation details to Python code :( Do other implementations support |
|
PY_YIELD
leaks internalasync_generator_wrapped_value
object #129013